﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Vehicle.aspx.cs" Inherits="Mercator2.Vehicle" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <asp:SqlDataSource ID="VehicleDS" runat="server" 
        ConnectionString="<%$ ConnectionStrings:MERCATOR_histConnectionString %>" 
        DeleteCommand="DELETE FROM [Vehicle] WHERE [VRN] = @original_VRN" 
        InsertCommand="INSERT INTO [Vehicle] ([VRN], [DriverID], [Brand], [Model], [Color], [Year]) VALUES (@VRN, @DriverID, @Brand, @Model, @Color, @Year)" 
        OldValuesParameterFormatString="original_{0}" 
        SelectCommand="SELECT * FROM [Vehicle]" 
        
        UpdateCommand="UPDATE [Vehicle] SET [DriverID] = @DriverID, [Brand] = @Brand, [Model] = @Model, [Color] = @Color, [Year] = @Year WHERE [VRN] = @original_VRN">
        <DeleteParameters>
            <asp:Parameter Name="original_VRN" Type="String" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="VRN" Type="String" />
            <asp:Parameter Name="DriverID" Type="Int32" />
            <asp:Parameter Name="Brand" Type="String" />
            <asp:Parameter Name="Model" Type="String" />
            <asp:Parameter Name="Color" Type="String" />
            <asp:Parameter Name="Year" Type="String" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="DriverID" Type="Int32" />
            <asp:Parameter Name="Brand" Type="String" />
            <asp:Parameter Name="Model" Type="String" />
            <asp:Parameter Name="Color" Type="String" />
            <asp:Parameter Name="Year" Type="String" />
            <asp:Parameter Name="original_VRN" Type="String" />
        </UpdateParameters>
    </asp:SqlDataSource>
    Cadastro de Veículos<br />
    <asp:Button ID="btnSearch" runat="server" onclick="btnSearch_Click" 
        Text="Procurar por placa do veículo:" Width="186px" />
    <asp:TextBox ID="txtVRN" runat="server"></asp:TextBox>
    <br />
    <asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True" 
        AutoGenerateRows="False" BackColor="White" BorderColor="#E7E7FF" 
        BorderStyle="None" BorderWidth="1px" CellPadding="3" DataKeyNames="VRN" 
        DataSourceID="VehicleDS" GridLines="Horizontal" Height="50px" Width="324px">
        <AlternatingRowStyle BackColor="#F7F7F7" />
        <EditRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
        <Fields>
            <asp:BoundField DataField="VRN" HeaderText="Placa" ReadOnly="True" 
                SortExpression="VRN" />
            <asp:BoundField DataField="DriverID" HeaderText="Motorista" 
                SortExpression="DriverID" />
            <asp:BoundField DataField="DriverID" HeaderText="DriverID" 
                SortExpression="DriverID" Visible="False" />
            <asp:BoundField DataField="Brand" HeaderText="Marca" SortExpression="Brand" />
            <asp:BoundField DataField="Model" HeaderText="Modelo" SortExpression="Model" />
            <asp:BoundField DataField="Color" HeaderText="Cor" SortExpression="Color" />
            <asp:BoundField DataField="Year" HeaderText="Ano" SortExpression="Year" />
            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" 
                ShowInsertButton="True" />
        </Fields>
        <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
        <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
        <PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
        <RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
    </asp:DetailsView>
</asp:Content>
